package com.hjb.service.impl.user;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hjb.service.config.constant.Constants;
import com.hjb.service.domain.siteuser.SiteUserAddRate;
import com.hjb.service.domain.siteuser.SiteUserAddRateExample;
import com.hjb.service.mapper.SiteUserAddRateMapper;
import com.hjb.service.user.SiteUserAddRateService;
import com.hjb.service.utils.HJBUT;

/**
 * 活期产品 加息 接口业务实现类
 * @author zhangxl
 * @date 2017-07-20
 * @version 1.0
 */
@Service
public class SiteUserAddRateServiceImpl implements SiteUserAddRateService{

	private Logger log = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private SiteUserAddRateMapper siteUserAddRateMapper;
	
	@Override
	public List<SiteUserAddRate> selectByExample(SiteUserAddRateExample example) {
		return siteUserAddRateMapper.selectByExample(example);
	}

	@Override
	public int selectByExampleCount(SiteUserAddRateExample example) {
		return siteUserAddRateMapper.selectCountByExample(example);
	}

	@Override
	public void updateUserAddRateStatus() {
		try {
			log.info("活期加息任务更新状态开始：.........................."+HJBUT.currentTime());
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("status", Constants.COMMON_STATUS_1);
			params.put("updateTime", HJBUT.currentTime());
			params.put("endDate", HJBUT.currentDate(-1));
			int res = siteUserAddRateMapper.updateUserAddRateStatus(params);
			log.info("活期加息任务更新状态结束：.........................."+HJBUT.currentTime()+",共计更新："+res);
		} catch (Exception e) {
			log.info("活期加息任务更新状态异常：.........................."+HJBUT.currentTime()+e.getStackTrace());
		}
	}

}
